package com.efast.dmom.aps.datahandlers;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.efast.cafe.framework.util.SpringWebUtils;
import com.efast.dmom.aps.bean.PlanOrderPartAnalysisResultItem;
import com.efast.dmom.aps.dao.PlanOrderPartAnalysisResultItemDao;
import com.efast.dmom.aps.entity.PlanOrderPartAnalysisResultItemEntity;
import com.efast.dmom.aps.util.TimeUtil;

@Component
public class PlanOrderPartAnalysisResultItemDataHandler {

	@Autowired
	private PlanOrderPartAnalysisResultItemDao planOrderPartAnalysisResultItemDao;

	public void saveList(List<PlanOrderPartAnalysisResultItem> itemList) {
		List<PlanOrderPartAnalysisResultItemEntity> list = new ArrayList<PlanOrderPartAnalysisResultItemEntity>();
		int i = 0;
		for (PlanOrderPartAnalysisResultItem obj : itemList) {
			i = i + 1;
			obj.getInnerData().setName("结果"+i);
			obj.getInnerData().setSiteId(DataHandlerUtils.getSiteId());
			obj.getInnerData().setCreationTime(TimeUtil.getLocalDateTime());
			obj.getInnerData().setCreationTimeZone(TimeUtil.getLocalTimeZone());
			obj.getInnerData().setCreator(SpringWebUtils.getRequestUser());
			obj.getInnerData().setLastModifiedTime(TimeUtil.getLocalDateTime());
			obj.getInnerData().setLastModifiedTimeZone(TimeUtil.getLocalTimeZone());
			obj.getInnerData().setLastModifier(SpringWebUtils.getRequestUser());
			obj.getInnerData().setCreationPid(1);
			obj.getInnerData().setLastModifiedPid(1);
			obj.getInnerData().setRowStatus(1);
			obj.getInnerData().setRowTrxId(1);
			list.add(obj.getInnerData());
		}
		planOrderPartAnalysisResultItemDao.saveList(list);
	}

	public void deleteAll() {
		planOrderPartAnalysisResultItemDao.deleteAll();		
	}

}
